package com.wx.pay.controller;

import com.wx.pay.common.ResultData;
import com.wx.pay.service.WXPayService;
import com.wx.pay.vo.PayVO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author 朝花不迟暮
 * @version 1.0
 * @date 2021/2/10 15:52
 */
@RestController
@RequestMapping("/pay")
public class WXPayController
{
    private static final Logger LOGGER = LoggerFactory.getLogger(WXPayController.class);
    @Autowired
    private WXPayService wxPayService;

    @PostMapping("/doUnifiedOrder")
    public ResultData doUnifiedOrder(PayVO payVO, BindingResult bindingResult) throws Exception
    {
        return wxPayService.doUnifiedOrder(payVO);
    }

    @PostMapping("/wxPayCallback")
    public void wxAppletPayCallback(HttpServletRequest request, HttpServletResponse response)
    {
        wxPayService.wxAppletPayCallback(request, response);
    }
}
